//package com.game.web.gateway.balance;
//
//import org.springframework.cloud.client.ServiceInstance;
//import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
//import org.springframework.stereotype.Service;
//import org.springframework.web.server.ServerWebExchange;
//
//@Service
//public class UserLoadBalancerClientFilter extends LoadBalancerClientFilter {
//
//    public UserLoadBalancerClientFilter(LoadBalancerClient loadBalancer) {
//        super(loadBalancer);
//    }
//
//    protected ServiceInstance choose(ServerWebExchange exchange) {
//        //从header中获取token，做为负载服务实例的key,同一个用户的token都是一样的
////        String routekey = exchange.getRequest().getHeaders().getFirst(GameConstants.USER_TOKEN);
////        if (routekey != null) {
////            if (this.loadBalancer instanceof RibbonLoadBalancerClient) {
////                RibbonLoadBalancerClient client = (RibbonLoadBalancerClient) this.loadBalancer;
////                String serviceId = ((URI) exchange.getAttribute(GATEWAY_REQUEST_URL_ATTR)).getHost();
////                return client.choose(serviceId, routekey);
////            }
////        }
//        return super.loadBalancer.choose(exchange.getRequest().getId());
//    }
//
//}
